package com.ming.reggie.controller;

import com.ming.reggie.common.R;
import com.ming.reggie.entity.Orders;
import com.ming.reggie.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired(required = false)
    private OrderService orderService;

    @RequestMapping("/submit")
    public R<String> submit(@RequestBody Orders orders, HttpSession session){
        Long userId = (Long) session.getAttribute("user");

        orderService.addOrder(orders,userId);

        return R.success("下单成功");
    }
}
